import collections
from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        dict_list = collections.defaultdict(list)
        for item in strs:
            _str = ''.join(sorted(item))
            print(item)
            dict_list[_str].append(item)
        return list(dict_list.values())


solution = Solution()
print(solution.groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]))

